package main

import (
	"fmt"
	"log"
	"sync"

	"example.com/singletonconfigdcl/singleton"
)

func main() {
	var wg sync.WaitGroup
	wg.Add(5)

	for i := 0; i < 5; i++ {
		go func(id int) {
			defer wg.Done()

			cfg, err := singleton.GetConfig()
			if err != nil {
				log.Printf("[worker-%d] get config failed: %v\n", id, err)
				return
			}
			fmt.Printf("[worker-%d] config address=%p, app=%s@%s\n",
				id, cfg, cfg.App.Name, cfg.App.Version)
		}(i)
	}

	wg.Wait()
}
